package com.boge.ai.prompt;

import okhttp3.*;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

public class Demo1 {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .readTimeout(20, TimeUnit.SECONDS)
                .connectTimeout(20, TimeUnit.SECONDS)
                .build();
        MediaType mediaType = MediaType.parse("application/json");



        String prompt = """
                {
                        "model": "gpt-4o",
                        "messages": [
                            {
                                "role": "user",
                                "content": "请将文本分为中性、否定或肯定文本：我觉得食物还可以。情绪："
                            }
                        ]
                }
        """;

        //RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n      \"content\": \"You are a helpful assistant\",\n      \"role\": \"system\"\n    },\n    {\n      \"content\": \"你好啊，你能介绍下中国吗?>\",\n      \"role\": \"user\"\n    }\n  ],\n  \"model\": \"gpt-4o\"}");
        RequestBody body = RequestBody.create(mediaType, prompt);
        Request request = new Request.Builder()
                .url("https://api.openai-hk.com/v1/chat/completions")
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("Accept", "application/json")
                .addHeader("Authorization", "Bearer hk-w3q3id1000054953c829f33c861457133e3048fa220f1076")
                .build();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}
